﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
    <![endif]-->
    <title>注册页面</title>
    <script src="http://apps.bdimg.com/libs/jquery/1.11.3/jquery.min.js"></script>
    <link href="css/pages.css" rel="stylesheet" />
    <link href="css/Mlogin.css" rel="stylesheet" />


</head>
<body>
    <div id="login">
        <div class="tabs">
            <ul>
                <li>用户注册</li>
            </ul>
        </div>
        <div class="content">
            <div class="tabbox active">
                <form>
                    <label for="InputUserName">姓名：</label>
                    <input id="InputUserName" name="username" type="text" placeholder="请输入真实姓名" />
                    <label for="InputIPhone">联系方式：</label>
                    <input id="InputIPhone" name="phonenum" type="text" placeholder="请输入正确手机号" />
                </form>
                <button onclick="UserRegister()">提 交</button>
            </div>
        </div>
    </div>
</body>
</html>

<!-- <input type="hidden" value="@ViewData["code"]" id="hidcode" />
<input type="hidden" value="@ViewData["weixininfo"]" id="hidweixininfo" /> -->
<script type="text/javascript">

	var url = location.href.split('#')[0];

	var start = url.indexOf("code=");

	var end = url.indexOf("&");

	var code = url.substring(start+5,end);
	
    function UserRegister() {

        var userName = $("#InputUserName").val();
        var Tel = $("#InputIPhone").val();

        if (userName.length <= 0 || Tel.lenght <= 0) {
            alert("姓名/手机号不能为空!");
            return;
        }

        var myreg = /^(((13[0-9]{1})|(14[0-9]{1})|(17[0]{1})|(15[0-3]{1})|(15[5-9]{1})|(18[0-9]{1}))+\d{8})$/;
        if (Tel.length != 11) {
            alert("请输入有效的手机号码！");
            return;
        } else if (!myreg.test(Tel)) {
            alert("请输入有效的手机号码！");
            return;
        } 
        $.ajax({
            type: "POST", 
       	    url:"WeChatAction_register.action",
         	data:{
         		username:$("#InputUserName").val(),
         		phone:$("#InputIPhone").val(),
         		code:code
         	},
        	dataType:"json",
             success: function (data) { 
                msg = eval("(" + data + ")");
                if (msg.info == true) {
                    alert("注册成功！");
                    WeixinJSBridge.call("closeWindow");
                } else if(msg.info==false){
                    alert("对不起，你已经注册成功！！不能再次注册！！");
                }
            },
            error: function (err) {
                alert("服务器异常，注册失败！！");
            }
        })
    }
</script>